package com.example.goodpet.db.dao;

import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;
import androidx.room.Update;

import com.example.goodpet.db.entity.User;

import java.util.List;

@Dao
public interface UserDAO {

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    void insert(User user);

    @Query("select * from user where phoneNumber = :arg0")
    User queryUser(String arg0);

    /**
     * 根据nickname模糊查询
     * @param nickname
     * @return
     */
    @Query("select * from user where nickname like :nickname limit :begin,:size")
    List<User> queryListUser(String nickname,int begin,int size);

    @Query("update user set portrait= :portrait where id= :userId")
    void updatePortrait(long userId,String portrait);

    @Query("update user set nickname= :nickname,gender= :gender,signature= :signature where id= :userId")
    void updateInfo(long userId,String nickname,String signature,int gender);

}
